package com.itjeffrey.autocode.controller;

import com.itjeffrey.autocode.bo.ScheduleJobLogTbBO;
import com.itjeffrey.autocode.common.Result;
import com.itjeffrey.autocode.service.ScheduleJobLogTbService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @From: Jeffrey
 * @Date: 2021/6/19
 */
@RestController
@RequestMapping("/schedule/job/log")
public class ScheduleJobLogTbController {

    @Resource
    private ScheduleJobLogTbService scheduleJobLogTbService;

    /**
     * 删除任务日志，支持批量
     * @param ids
     * @return
     */
    @PostMapping("/delete")
    public ResponseEntity<Result> delete(@RequestBody List<Integer> ids){
        return ResponseEntity.ok(scheduleJobLogTbService.delete(ids));
    }

    /**
     * 导出任务日志，支持批量
     * @param scheduleJobLogTbBOS
     * @return
     */
    @PostMapping("/export")
    public ResponseEntity<Void> export(@RequestBody List<ScheduleJobLogTbBO> scheduleJobLogTbBOS,
                                         HttpServletResponse response){
        scheduleJobLogTbService.export(scheduleJobLogTbBOS, response);
        return ResponseEntity.ok().build();
    }

    /**
     * 查询任务日志列表
     * @param scheduleJobLogTbBO
     * @return
     */
    @PostMapping("/queryList")
    public ResponseEntity<Result> queryList(@RequestBody ScheduleJobLogTbBO scheduleJobLogTbBO){
        return ResponseEntity.ok(scheduleJobLogTbService.queryList(scheduleJobLogTbBO));
    }

}
